 

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'organizers-form',
	'enableAjaxValidation'=>false,
	'htmlOptions'=>array(
		'class'=>'horizontal-form',
        'enctype'=>'multipart/form-data',  
    ),
)); ?>

	<?php echo $form->errorSummary($model); ?>
<div class="form-body">
    <div class="row">
    	<div class="col-md-3" style="overflow: hidden;">
	       <fieldset>
        	<legend><strong>Ảnh đại diện</strong></legend>
            <!-- Event Image -->
            <div class="fileinput fileinput-new btn-block" data-provides="fileinput">
                <?php if ($model->image != null) : ?>
                <div class="fileinput-new thumbnail" style="width:100%;">
                    <img src="<?php echo IMAGES_URL.'Organizers/' . $model->image; ?>" alt="..." width="100%">
                </div>
                <input type="hidden" value="<?php echo $model->image; ?>" name="Organizers[image]" />
                <?php endif; ?>
                <div class="fileinput-preview fileinput-exists thumbnail" style="max-width:100%"></div>
                <div>
                    <span class="btn btn-default btn-file btn-block"><span class="fileinput-new">Chọn ảnh</span><span class="fileinput-exists">Chọn ảnh khác</span>
                    <?php echo $form->fileField($model, 'image', array('class'=>'default')); ?>
                    </span>
                    <a href="#" class="btn btn-default fileinput-exists btn-block" data-dismiss="fileinput">Xóa bỏ ảnh hiện tại</a>
                </div>
            </div>
            	 <?php if(Yii::app()->user->hasFlash('error')): ?>
		                <div class="errorMessage">
		                    <?php echo Yii::app()->user->getFlash('error'); ?>
		                </div>
	                <?php endif; ?>
        </fieldset>
 		</div>
 		<div class="col-md-9">
 			<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'title', array('class'=>'control-label')); ?>
				<?php echo $form->textField($model,'title', array('class'=>'form-control')); ?>
				<?php echo $form->error($model,'title', array('class'=>'help-block')); ?>
			</div>
 			<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'brief', array('class'=>'control-label')); ?>
				<?php echo $form->textArea($model,'brief', array('class'=>'form-control','rows'=>5)); ?>
				<?php echo $form->error($model,'brief', array('class'=>'help-block')); ?>
			</div>
			<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($o_profile,'description', array('class'=>'control-label')); ?>
				<?php echo $form->textArea($o_profile,'description', array('class'=>'form-control','rows'=>5)); ?>
			</div>
		
		<div class="col-md-6 row">
	 		<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'phone', array('class'=>'control-label')); ?>
				<?php echo $form->textField($model,'phone', array('class'=>'form-control')); ?>
				<?php echo $form->error($model,'phone', array('class'=>'help-block')); ?>
			</div>
	 		<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'altphone', array('class'=>'control-label')); ?>
				<?php echo $form->textField($model,'altphone', array('class'=>'form-control')); ?>
				<?php echo $form->error($model,'altphone', array('class'=>'help-block')); ?>
			</div>
			<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'fax', array('class'=>'control-label')); ?>
				<?php echo $form->textField($model,'fax', array('class'=>'form-control')); ?>
				<?php echo $form->error($model,'fax', array('class'=>'help-block')); ?>
			</div>
			<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'email', array('class'=>'control-label')); ?>
				<?php echo $form->textField($model,'email', array('class'=>'form-control')); ?>
				<?php echo $form->error($model,'email', array('class'=>'help-block')); ?>
			</div>
 			<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'website', array('class'=>'control-label')); ?>
				<?php echo $form->textField($model,'website', array('class'=>'form-control')); ?>
				<?php echo $form->error($model,'website', array('class'=>'help-block')); ?>
			</div>

		</div>
		<div class="col-md-6">
		    <div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'address', array('class'=>'control-label')); ?>
				<?php echo $form->textField($model,'address', array('class'=>'form-control')); ?>
				<?php echo $form->error($model,'address', array('class'=>'help-block')); ?>
			</div>
	 		<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'ward', array('class'=>'control-label')); ?>
				<?php echo $form->textField($model,'ward', array('class'=>'form-control')); ?>
				<?php echo $form->error($model,'ward', array('class'=>'help-block')); ?>
			</div>
	 		<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'district_id', array('class'=>'control-label')); ?>
				<?php echo $form->dropDownList($model,'district_id',CHtml::listData(Districts::model()->findAll(array('order' =>'name')),'id','name'),array('empty'=>'Select Districts','class'=>'form-control')); ?>
				<?php echo $form->error($model,'district_id', array('class'=>'help-block')); ?>
			</div>
	 		<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'city_id', array('class'=>'control-label')); ?>
				<?php echo $form->dropDownList($model,'city_id',CHtml::listData(Cities::model()->findAll(array('order' =>'name')),'id','name'),array('empty'=>'Select City','class'=>'form-control'));?>
				<?php echo $form->error($model,'city_id', array('class'=>'help-block')); ?>
			</div>
	 		<div class="form-group <?php echo ($model->getError('title') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model,'country_id', array('class'=>'control-label')); ?>
				<?php echo $form->dropDownList($model,'country_id',CHtml::listData(Countries::model()->findAll(array('order' =>'name')),'id','name'),array('empty'=>'Select Countries','class'=>'form-control')); ?>
				<?php echo $form->error($model,'country_id', array('class'=>'help-block')); ?>
			</div>
		</div>

			<!-- PLACE SOCIAL -->
			<fieldset>
				<legend><strong>Social</strong></legend>
			        <div class="col-md-12 row">
			            <div id="listSocial">
			                <?php if ($model->isNewRecord):?>
			                    <div class="row">
			                        <div class="col-md-5">
			                            <div class="form-group <?php echo ($s_social->getError('social_id') ? 'has-error' : ''); ?>">
			                                <?php echo CHtml::activelabelEx($s_social, 'social_id', array('class'=>'control-label')); ?>
			                                <?php echo CHtml::dropDownList('ArtistSocial[social_id][]', '',PlaceSocial::model()->getSocial(), array('class'=>'form-control', 'prompt'=>'Chọn Social')); ?>
			                                <?php echo CHtml::error($s_social, 'social_id', array('class'=>'help-block')); ?>
			                            </div>
			                        </div>
			                        <div class="col-md-1">AND</div>
			                        <div class="col-md-6">
			                            <div class="form-group <?php echo ($s_social->getError('url') ? 'has-error' : ''); ?>">
			                                <?php echo CHtml::activelabelEx($s_social, 'url', array('class'=>'control-label')); ?>
			                                <?php echo CHtml::textField('ArtistSocial[url][]', '', array('class'=>'form-control',)); ?>
			                                <?php echo CHtml::error($s_social, 'url', array('class'=>'help-block')); ?>
			                            </div>
			                        </div>
			                    </div>
			                <?php else:?>
			                    <?php foreach($s_social as $data):?>
			                        <div class="row">
			                            <div class="col-md-5">
			                                <div class="form-group <?php echo ($data->getError('social_id') ? 'has-error' : ''); ?>">
			                                    <?php echo CHtml::activelabelEx($data, 'social_id', array('class'=>'control-label')); ?>
			                                    <?php echo CHtml::dropDownList('ArtistSocial[social_id][]', $data->social_id,PlaceSocial::model()->getSocial(), array('class'=>'form-control', 'prompt'=>'Chọn Social')); ?>
			                                    <?php echo CHtml::error($data, 'social_id', array('class'=>'help-block')); ?>
			                                </div>
			                            </div>
			                            <div class="col-md-1">AND</div>
			                            <div class="col-md-6">
			                                <div class="form-group <?php echo ($data->getError('url') ? 'has-error' : ''); ?>">
			                                    <?php echo CHtml::activelabelEx($data, 'url', array('class'=>'control-label')); ?>
			                                    <?php echo CHtml::textField('ArtistSocial[url][]', $data->url, array('class'=>'form-control',)); ?>
			                                    <?php echo CHtml::error($data, 'url', array('class'=>'help-block')); ?>
			                                </div>
			                            </div>
			                        </div>
			                    <?php endforeach;?>
			                <?php endif;?>
			            </div>
						<a href="javascript: void(0);" class="btn green pull-right" onclick="addSocial();"><i class="icon-plus"> </i> Thêm Social</a>
			        </div>
			    </fieldset>
		</div>
      </div>
</div>
                <?php echo CHtml::submitButton('Create', array('class'=>'btn green', 'style'=>'margin-right : 10px'));?>
                <?php echo CHtml::submitButton('Refresh', array('onClick'=>'window.location="'.Yii::app()->getRequest()->getUrl().'"','class'=>'btn btn-beoro-3','style'=>'margin-right : 10px'));?>
                <?php echo CHtml::submitButton('Back', array('onClick'=>'history.go(-1)','class'=>'btn btn-beoro-3', 'style'=>'margin-right : 10px'));?>
 
   
        <?php $this->endWidget(); ?>
 
  <script type="text/javascript">
var i = 1;
function addSocial()
{
    $.ajax({
        url: '<?php echo Yii::app()->createUrl("/Events/request/organizersAddSocial");?>',
        type: 'post',
        data: {i: i},
        success: function (data)
        {
             i = i+ 1;
            $(data).appendTo('#listSocial');
        }
    });
}
 </script>